/// @tags: MinMaxExclusion DPonTree
#include <cctype>
#include <cstdio>
#include <iostream>
using std::cerr;
using std::endl;

namespace BlueQuantum {

typedef long long ll;

int const N = 18, mod = 998244353;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

struct Edge {
  int v, nxt;
} e[N << 1];

int n, Q, x, e_cnt, status;
int ans[1 << N], heads[N], deg[N], A[N], B[N], f[1 << N], dp[N];

inline int qpow(ll base, int exp) {
  ll res = 1;
  while (exp) {
    if (exp & 1) (res *= base) %= mod;
    exp >>= 1;
    (base *= base) %= mod;
  }
  return res;
}

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, deg[v]++;
}

void solve(int u, int fa) {
  A[u] = B[u] = 0;
  if ((status >> (u - 1)) & 1) return;
  int sumA = 0, sumB = 0;
  for (int i = heads[u], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      solve(v, u);
      sumA += A[v], sumB += B[v];
      if (sumA >= mod) sumA -= mod;
      if (sumB >= mod) sumB -= mod;
    }
  }
  if ((sumA = deg[u] - sumA) < 0) sumA += mod;
  A[u] = qpow(sumA, mod - 2);
  B[u] = 1ll * A[u] * (deg[u] + sumB >= mod ? deg[u] + sumB - mod : sumB + deg[u]) % mod;
}

inline void FWT(int *const f) {
  int maxl = 1 << n;
  for (int i = 2; i <= maxl; i <<= 1) {
    int mid = i >> 1;
    for (int j = 0; j < maxl; j += i) {
      for (int k = 0; k < mid; ++k) {
        if ((f[j + k + mid] += f[j + k]) >= mod) f[j + k + mid] -= mod;
      }
    }
  }
}

inline int main() {
  read(n), read(Q), read(x);
  for (int i = 1, u, v; i < n; ++i) {
    read(u), read(v);
    add(u, v), add(v, u);
  }
  for (status = 1; status < 1 << n; ++status) {
    solve(x, x);
    f[status] = (__builtin_popcount(status) & 1) ? B[x] : -B[x];
    if (f[status] < 0) f[status] += mod;
  }
  FWT(f);
  for (int k, sta = 0, a; Q; --Q, sta = 0) {
    read(k);
    for (int i = 1; i <= k; ++i) sta |= (1 << (read(a) - 1));
    printf("%d\n", f[sta]);
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P5643 [PKUWC2018] 随机游走.in", "r", stdin);
  freopen("P5643 [PKUWC2018] 随机游走.out", "w", stdout);
#endif
#endif

  return BlueQuantum::main();
}